<?php
/**
 * Created by PhpStorm.
 * User: junyv
 * Date: 2017/4/3
 * Time: 16:53
 */

namespace app\mobile\controller;


class Huodong extends Base
{
    public function _initialize()
    {
        parent::_initialize();
        $cate = cache('activityCate');
        $this->assign('cate',$cate['cate']);
    }
    public function index(){
        $cate_id = input('param.cate_id/d',0);
        $cate_id && $where['cate_id'] = $cate_id;
        $where['status'] = 1;
        $where['city']   = $this->cityInfo['id'];
        $lists = model('activity')->where($where)->field('id,title,img,create_time,description,begin_time,end_time')->order('ordid asc,id desc')->paginate(16);
        $this->assign('cate_id',$cate_id);
        $this->assign('lists',$lists);
        $this->assign('pages',$lists->render());
        $this->assign('title','活动');

        return $this->fetch();
    }
    public function detail(){
        $id = input('param.id/d',0);
        if($id){
            $info = model('activity')->where(['status'=>1,'id'=>$id])->find();
            if(!$info){
                return $this->fetch('public/404');
            }
            model('activity')->where(['id'=>$id])->setInc('hits');
            $this->assign('info',$info);
        }else{
            return $this->fetch('public/404');
        }
        $this->setSeo($info);
        return $this->fetch();
    }
}